
if [ $1 -eq 0 ]
then
    SPEED=$1
    BUFFER_SIZE=$2
    tc qdisc del dev enp1s0f1 root
    echo "qdisc del dev enp1s0f1 root"
else
    # speed in Mbps
    SPEED=$1
    KB_SPEED=$(echo "($SPEED * 1000) / 1" | bc)

    # in bytes. Must be atleast 1500 bytes (1 packet)
    BUFFER_SIZE=$2

    #todo add delay
    tc qdisc replace dev enp1s0f1 root tbf rate $KB_SPEED.kbit limit $BUFFER_SIZE burst 12kbit
    echo "tc qdisc replace dev enp1s0f1 root tbf rate ${KB_SPEED}.kbit limit ${BUFFER_SIZE} burst 12kbit"
fi


mmdelay=$3
cc_name=$4


ethtool -K enp1s0f1 gso off
ethtool -K enp1s0f1 tso off
sysctl -w net.ipv4.tcp_sack=0

tcpdump -i enp1s0f1 -s 61 dst 11.11.11.2 or src 11.11.11.2 -w cellsim_hombre_${SPEED}_${BUFFER_SIZE}_${mmdelay}_${cc_name}.pcap &
sleep 40
pkill -9 tcpdump